{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('phoneBill');}">话费兑换</a></li>
</ul>
<form action="./index.php" method="get" class="form-horizontal">
    <input type="hidden" name="c" value="site">
    <input type="hidden" name="a" value="entry">
    <input type="hidden" name="m" value="bh_farm">
    <input type="hidden" name="do" value="phoneBill">
    <div class="form-group">
        <label class="col-xs-12 col-sm-1 control-label">用户昵称</label>
        <div class="col-sm-2 col-xs-12">
            <input type="text" class="form-control" name="nickname"  value="{$nickname}" />
        </div>
        <label class="col-xs-12 col-sm-1 control-label">状态</label>
        <div class="col-sm-2 col-xs-12">
            <select name="status">
                <option value="0">请选择 </option>
                <option value="1"  {if $status = 1} selected {/if}>未充值</option>
                <option value="2"  {if $status = 2} selected {/if}>已经充值</option>
                <option value="3"  {if $status = 3} selected {/if}>拒绝</option>
            </select>
        </div>
        <div class="col-xs-12 col-sm-2 col-md-2 col-lg-2">
            <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
        </div>
    </div>
</form>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:60px;">id</th>
                <th style="width:60px;">金额</th>
                <th style="width:80px;">用户昵称</th>
                <th style="width:80px;">电话号码</th>
                <th style="width:80px;">状态</th>
                <th style="width:100px;">时间</th>
                <th style="width:100px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $phoneBill['list'] $item}
            <tr>
                <td>{$item['id']}</td>
                <td>{$item['money']}</td>
                <td>{$item['nickname']}</td>
                <td>{$item['phone']}</td>
                <td>{$item['statusStr']}</td>
                <td>{php echo date('Y-m-d H:i:s',$item['created'])}</td>
                <td>
                    {if $item['status'] ==1}
                    <a href="javascript:;" data-id="{$item['id']}" class="success btn btn-success btn-sm">充值</a>
                    <a href="javascript:;" data-id="{$item['id']}" class="successPay btn btn-success btn-sm">聚合充值</a>
                    <a href="javascript:;" data-id="{$item['id']}" class="waring btn btn-warning btn-sm">拒绝</a>
                    {/if}
                    <a href="javascript:;" id="{$item['id']}" class="delete btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    {$phoneBill['pages']}
</div>
{template 'footer'}
<script type="application/javascript">
    $(function () {
        $('.delete').click(function () {
            if (!confirm('确认要删除此分类?')) {
                return false;
            }
            id = $(this).attr('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });


        $('.success').blur(function () {
            var  id = $(this).data('id');
            $.post('', {id:id, op:'success'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('充值失败');
                }

            }, 'json')
        });


        $('.successPay').blur(function () {
            var  id = $(this).data('id');
            $.post('', {id:id, op:'successPay'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('充值失败');
                }

            }, 'json')
        });


        $('.waring').click(function () {
            id = $(this).data('id');
            $.post('', {id:id, op:'waring'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('拒绝失败');
                }

            }, 'json')
        });
    });

</script>